package com.ruoyi.project.price.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.price.domain.BinsAccount;
import com.ruoyi.project.price.service.IBinsAccountService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * acountController
 * 
 * @author admin
 * @date 2025-04-02
 */
@RestController
@RequestMapping("/price/account")
public class BinsAccountController extends BaseController
{
    @Autowired
    private IBinsAccountService binsAccountService;

    /**
     * 查询acount列表
     */
    @PreAuthorize("@ss.hasPermi('price:account:list')")
    @GetMapping("/list")
    public TableDataInfo<BinsAccount> list(BinsAccount binsAccount)
    {
        startPage();
        List<BinsAccount> list = binsAccountService.selectBinsAccountList(binsAccount);
        logger.info("list:{}", list);
        logger.info("list:{}", TableDataInfo.build(list));
        return TableDataInfo.build(list);
    }

    /**
     * 导出acount列表
     */
    @PreAuthorize("@ss.hasPermi('price:account:export')")
    @Log(title = "acount", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BinsAccount binsAccount)
    {
        List<BinsAccount> list = binsAccountService.selectBinsAccountList(binsAccount);
        ExcelUtil<BinsAccount> util = new ExcelUtil<BinsAccount>(BinsAccount.class);
        util.exportExcel(response, list, "acount数据");
    }

    /**
     * 获取acount详细信息
     */
    @PreAuthorize("@ss.hasPermi('price:account:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(binsAccountService.selectBinsAccountById(id));
    }

    /**
     * 新增acount
     */
    @PreAuthorize("@ss.hasPermi('price:account:add')")
    @Log(title = "acount", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BinsAccount binsAccount)
    {
        return toAjax(binsAccountService.insertBinsAccount(binsAccount));
    }

    /**
     * 修改acount
     */
    @PreAuthorize("@ss.hasPermi('price:account:edit')")
    @Log(title = "acount", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BinsAccount binsAccount)
    {
        return toAjax(binsAccountService.updateBinsAccount(binsAccount));
    }

    /**
     * 删除acount
     */
    @PreAuthorize("@ss.hasPermi('price:account:remove')")
    @Log(title = "acount", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(binsAccountService.deleteBinsAccountByIds(ids));
    }
}
